package com.beiding.jsonanalyzer.analyze.query.queryfunc;

import com.beiding.jsonanalyzer.analyze.query.Comparator;
import com.beiding.jsonanalyzer.analyze.query.ComparatorResult;

/**
 * @author 丁常磊
 * @date 2022/6/27 10:56
 */

public class Matches implements Comparator {

    @Override
    public ComparatorResult compare(Object keyValue, Object valueValue) {
        if (keyValue instanceof String && valueValue instanceof String) {
            return ((String) keyValue).matches((String) valueValue) ? ComparatorResult.TRUE : ComparatorResult.FALSE;
        }
        return null;
    }

    @Override
    public String toString() {
        return "matches";
    }
}
